package com.itheima.user.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.user.entity.UserEntity;
import com.itheima.user.mapper.UserMapper;
import com.itheima.user.service.UserService;
import com.itheima.user.vo.response.OrderResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean login(String userName, String password) {
        QueryWrapper<UserEntity> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(UserEntity::getUserName,userName).eq(UserEntity::getPassword,password);
        UserEntity userEntity = userMapper.selectOne(wrapper);
        return userEntity!=null;
    }

    @Override
    public UserEntity findUserById(Integer userId) {
        UserEntity userEntity = userMapper.selectById(userId);
        return userEntity;
    }

    @Override
    @SentinelResource("chain") // 声明资源名称 value=资源名
    public void dosomething() {

        System.out.println("chain");
    }
}
